/*
package com.ruoyi.libb.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {
    //日志
    private static Logger logger= LoggerFactory.getLogger(GlobalExceptionHandler.class);


    @ExceptionHandler(value = {Exception.class})
    @ResponseBody
    public Result exceptionHandler(Exception e){//捕获全局异常

        //异常记录
        StackTraceElement stackTraceElement = e.getStackTrace()[0];
        //异常类全路径
        logger.error("path: "+stackTraceElement.getClassName());
        //异常行数
        logger.error("line: "+stackTraceElement.getLineNumber());
        //异常信息
        logger.error("11111======="+e.toString()+"=======");

        //这里先判断拦截到的Exception是不是我们自定义的异常类型
        if(e instanceof AppException){
            AppException appException = (AppException)e;
            return Result.error(appException.getCode(),appException.getMsg());
        }
        System.out.println("全局异常捕获=>>"+e);

        //如果拦截的异常不是我们自定义的异常(例如：数据库主键冲突)
        return Result.error(500,"服务器端异常");
    }
}
*/
